function [XD,YD]=p_triangle(r,q,a)
% p_triangle: Return the vertices of a triangle
%
% SYNTAX:
%   [XD,YD] = p_triangle(r,q,a)
%   [XY] = p_triangle(r,q,a)
%   Return vertices of specified triangle with radius r, center angle q and angle spread a.

%   Author: Hongbin Ma
%   Last updated: 2009-6-2 with MATLAB 6.5
%   Problems or suggestions? Email me: mathmhb[at]163.com

XD=[0,r*cos(q-a),r*cos(q+a),0];
YD=[0,r*sin(q-a),r*sin(q+a),0];
if nargout<2,
    XD=[XD;YD]';
end;
